Skip to content

test(frontend): hold the drawer slides until the test presses Escape - #397

Merged
pdevito3 merged 1 commit into
mainfrom
test/drawer-slide-in-flake
Nov 1, 2026
Merged

pdevito3 merged 1 commit into
mainfrom
test/drawer-slide-in-flake

Conversation

@pdevito3

@pdevito3 pdevito3 commented Nov 1, 2026 •

Copy link
Copy Markdown
Owner

Why

CI must have no flaky tests. On #396, the api-contract job failed at drawer.test.tsx:170 with expected false to be true. That PR does not touch the drawer, and a rerun passed.

Cause

The React Aria Sheet ends its slide-in on the scrollend of its scroller. It ends its slide-out on a react-aria-sheet-close event. Each comes about 500 ms after the slide starts, on a real-time clock. CPU throttling does not slow it, even at 20x. The tests that press Escape "while it slides in" reach their data-entering check after 130 to 270 ms on a fast machine. A slow runner reaches it after the slide ended.

This is not a product bug. A real user can press Escape after the slide ends, and the drawer handles that too.

Fix

holdSlides() in the test file stops those two events before the Sheet gets them. endSlides() sends them again after the test presses Escape. onTestFinished also calls it. Six tests use it: each test that checks data-entering, and the "twice fast" test, which also raced the slide-out.

Proof

Run (10 copies of each test) Before After
No slow-down 0 failures 0 failures
300 ms pause before the check 10/10 in the CI test 0
600 ms pause before the check 10/10 in all six 0
Playwright slowMo: 150 10/10 in "twice fast" 0

With the #391 fix reverted (no CloseOnEscape in drawer.tsx), the four Escape tests still fail 3 of 3 times. So the tests still catch that bug.

pnpm lint, pnpm build, and pnpm test (524 tests) pass.

The drawer tests that press Escape while the drawer slides in checked that
the drawer still slides in. The React Aria Sheet ends its slide-in on the
scrollend of its smooth scroll, about 500 ms after the drawer opens. On a
slow runner the test reached that check after the slide ended, and failed.

Each such test now holds the scrollend of the sheet scroller and the
react-aria-sheet-close event of the overlay until the test pressed Escape,
then lets them through. The slides now end when the test says, on a runner
of any speed. With the Escape fix of #391 reverted, the four tests that
close the drawer on Escape still fail.
@pdevito3

pdevito3 commented Nov 1, 2026

Copy link
Copy Markdown
Owner Author

Independent verification of #397: PASS+NOTES

Goal: CI with no flaky drawer tests. I checked head 637b9dba in a detached worktree from origin/test/drawer-slide-in-flake. I made no commits.

Each loop ran pnpm vitest run --project browser <file> --reporter=json once per run, one run at a time. A script counted the failures per test from the JSON.

Check Runs Result
1a. main test file, await new Promise((r) => setTimeout(r, 600)) before each of the 6 data-entering checks 10 10/10 runs fail. Each of the 6 slide-in tests fails 10/10 with expected false to be true (the CI failure). The "after it slides in" test passes 10/10.
1b. PR test file, the same 6 pauses 10 0/10 runs fail. All 7 tests pass 10/10.
2. PR test file, no change 20 0/20 runs fail (140/140 tests pass).
3a. PR test file, drawer.tsx from 966ea5a8^ (no CloseOnEscape) 3 3/3 runs fail. 4 tests fail 3/3: "while it slides in", "over a dialog closes only the drawer", "over a dialog, twice fast", and "a menu item opened".
3b. PR test file with the 600 ms pauses, drawer.tsx from 966ea5a8^ 3 The same 4 tests fail 3/3.
4. pnpm lint and pnpm test in frontend 1 Both exit 0. Results: 60 files and 524 tests pass.

966ea5a8 is the last commit that changed drawer.tsx, so git show 966ea5a8^:frontend/src/components/ui/drawer.tsx is a full revert of #391. In 3b, a slow runner still catches the bug, because the held events keep the drawer in its slide.

I read react-aria-components@1.22.1 dist/private/Sheet.mjs. onEnter resolves on the scrollend of [data-sheet-scroll]. onExit resolves on the react-aria-sheet-close event that the IntersectionObserver sends on the overlay. Both listeners use once. So the hold stops the right events, and when the test sends them again, the slides end.

The CI checks on this PR pass.

Notes:

  • The PR says that pnpm test runs 513 tests. My local run shows 524. The number of tests does not change the result.
  • holdSlides uses private details of the React Aria Sheet: the two event names and data-sheet-scroll. If a React Aria update changes them, the hold stops nothing and gives no error. Then the tests can fail at random again on a slow runner, but each failure stops at the data-entering check. You do not need to change this PR. When you update react-aria-components, check these names again.

@pdevito3
pdevito3 merged commit bf2ccaf into main Nov 1, 2026
20 checks passed
@pdevito3
pdevito3 deleted the test/drawer-slide-in-flake branch November 1, 2026 23:47
pdevito3 added a commit that referenced this pull request Nov 4, 2026
The drawer tests hold scrollend on [data-sheet-scroll] and
react-aria-sheet-close. If an upgrade renames one, the hold catches
nothing, the flake from #397 comes back, and no test shows why.

A healthy run of the six tests that use the hold catches nothing on a fast
machine, so they cannot make the check. A new test waits for each event.
pdevito3 added a commit that referenced this pull request Nov 4, 2026
The drawer tests hold scrollend on [data-sheet-scroll] and
react-aria-sheet-close. If an upgrade renames one, the hold catches
nothing, the flake from #397 comes back, and no test shows why.

A healthy run of the six tests that use the hold catches nothing on a fast
machine, so they cannot make the check. A new test waits for each event.
pdevito3 added a commit that referenced this pull request Nov 4, 2026
…#427)

## Why

If a `react-aria-components` upgrade renames an event that the drawer
tests hold, the hold catches nothing and the flake from #397 comes back
with no failing test to explain it. This PR adds a test that fails with
a message that names the event.

Closes #405

## What changed

- A new test in `drawer.test.tsx` opens a drawer with the hold on, and
waits for `scrollend` on `[data-sheet-scroll]`. Then it presses Escape
and waits for `react-aria-sheet-close`. It also checks that the drawer
stays in `data-entering` and in `data-exiting` while the events are
held, and that it closes when they are released.
- `holdSlides()` now returns `{ endSlides, held }`, so that the new test
can read what it caught.

## Scope

- The check is in one new test, not in the six tests that use the hold.
On a fast machine those six tests hold nothing when they call
`endSlides()`, because they press Escape before the slide ends. An
assert in them would fail on a correct run.
- Known gap: `scrollend` is a browser event, so an upgrade cannot rename
it. An upgrade can stop waiting for it. The test catches that only if
the slide ends within about 50 ms of the event.

## Tradeoffs

- Each wait has a 10 s limit and the test has a 30 s limit. A correct
run ends each wait when the event arrives. A stall of up to about 10 s
in a wait does not fail the test. A longer stall fails it, and the
message names a stalled runner as a possible cause. The 30 s limit gives
a real rename its message and not a test timeout.

## Blast Radius

Only the drawer test file changes. The new test adds about 1.2 s to the
suite.

## Verification

- Five mistakes in the hold each fail only the new test, with a message
that names the fault: the `scrollend` listener, the
`react-aria-sheet-close` listener, the `data-sheet-scroll` attribute,
and each of the two events no longer stopped. Before this change, all
tests passed with both event names wrong.
- The drawer tests pass 25 of 25 runs, one at a time, with a machine
load average of about 100.
- `pnpm lint` passes, and `pnpm test` passes 628 of 628 on the final
base.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant